package com.spica.spicaschool

import android.os.Bundle
import android.os.PersistableBundle
import android.view.LayoutInflater
import androidx.navigation.Navigation
import androidx.navigation.fragment.findNavController
import com.spica.spicaschool.base.BindingActivity
import com.spica.spicaschool.databinding.ActivityContentBinding
import com.zackratos.ultimatebarx.ultimatebarx.UltimateBarX
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

@AndroidEntryPoint
class ContentActivity : BindingActivity<ActivityContentBinding>() {




  override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
    super.onCreate(savedInstanceState, persistentState)
    Navigation.findNavController(viewBinding.root.findViewById(R.id.fragment_container_view))
      .addOnDestinationChangedListener { _, destination, _ ->
        Timber.e("路由-日志:$destination")
      }
  }


  override fun onSupportNavigateUp(): Boolean {
    return Navigation.findNavController(this, findViewById(R.id.fragment_container_view))
      .navigateUp()
  }

  override fun initializer() {
    UltimateBarX.with(this)
      .light(true)
      .colorRes(R.color.white)
      .applyStatusBar()
    val navController = supportFragmentManager.findFragmentById(R.id.fragment_container_view)?.findNavController()
    navController?.setGraph(R.navigation.nav_main)
  }

  override fun setupViewBinding(inflater: LayoutInflater): ActivityContentBinding =
    ActivityContentBinding.inflate(layoutInflater)

}
